package com.bussiness.system.core.impl;

import com.bussiness.system.face.OssService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Arrays;
import java.util.Map;
import java.util.List;

import com.bussiness.system.query.OssEntityQuery;
import com.bussiness.system.entity.OssEntity;
import com.bussiness.system.form.OssEntityAuditForm;
import com.bussiness.system.core.OssCoreService;
import com.bussiness.system.util.Result;

/**
 * 文件上传
 *  核心业务书写
 * @author xlr
 * @email 402701653@qq.com
 * @date 2018-09-04 00:34:01
 */
@Service
public class OssCoreServiceImpl implements OssCoreService {


    @Autowired
    private OssService ossService;

    /**
    * 組合查詢
    * @param query
    * @return
    */
    @Override
    public Result queryPage(OssEntityQuery query) {

       return ossService.queryPage(query);
    }


    /**
    * 列表
    */
    @Override
    public Result list(OssEntityQuery query){

        Result page = ossService.queryPage(query);
        return page;
    }

    /**
    * 信息
    */
    @Override
    public Result info( Long id){
            OssEntity oss = ossService.selectById(id);
        if( null != oss){
            return new Result<OssEntity>().success(oss);
        }
        return new Result().error();
    }

    /**
    * 保存
    */
    @Override
    public Result save(OssEntityAuditForm oss){
        OssEntity entity = oss.transfer();
        boolean flag = ossService.insert(entity);

        if(flag){
            return new Result().success();
        }
        return new Result().error();
    }

    /**
    * 修改
    */
    @Override
    public Result update(OssEntityAuditForm oss){
        OssEntity entity = oss.transfer();
        boolean flag = ossService.updateById(entity);

        if(flag){
            return new Result().success();
        }
        return new Result().error();
    }

    /**
    * 删除
    */
    @Override
    public Result delete(Long[] ids){
        boolean flag = ossService.deleteBatchIds(Arrays.asList(ids));
        if(flag){
            return new Result().success();
        }
        return new Result().error();
    }
}
